#include <QtCore/QCoreApplication>
#include <QtGui/QApplication>
#include "backendserver.h"
#include "backendtest.h"
#include "fileserver.h"
#include "httpreader.h"



int main(int argc, char *argv[])
{
    #if defined(TESTING)
        QApplication a(argc, argv);
    #else
        QCoreApplication a(argc, argv);
    #endif
        QCoreApplication::setApplicationName("test");
    BackendServer * server=new BackendServer();
    FileServer * fileServer=new FileServer();
    if(!fileServer->startListening(7008)){
        return 0;
    }

    //HttpReader * reader=new HttpReader("gloriaandal.com",80,"http://gloriaandal.com/site/sites/default/files/Gym.mp4","ours.txt");
    //QFile file("siteoutput.txt");
    //QHttp * http=new QHttp("www.gloriaandal.com");
      //      http->get("http://www.gloriaandal.com/site/sites/default/files/Gym.mp4",&file);
   // QFile file2("myoutput.txt");
    //http->get("http://www.gloriaandal.com/site/sites/default/files/Gym.mp4",&file2);
    if(server->startListening(7007)) {
        qDebug()<<"server started";
        #if defined(TESTING)
            BackendTest * test= new BackendTest(QHostAddress::LocalHost,7007);
            test->start();
        #endif
    }
    //HttpReader * reader=new HttpReader("localhost",7008,"/5 HTTP/1.1","backend.txt");
    return a.exec();
}
